home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 6 / MacMania 6.toast / / Multimedia & Desktop / VideoToolbox / VideoToolboxSources / GDInfo.c < prev    next >
Text File  |  1996-09-05  |  6KB  |  166 lines

  1. /*
  2. GDInfo.c
  3.  
  4. GDInfo fills the user-supplied VideoInfo record with all the descriptive
  5. information that can be obtained quickly from the driver and GDevice record
  6. without disturbing the screen. Under 1-bit QuickDraw it ignores the card->device
  7. field.
  8.  
  9. GDInfoTime fills the user-supplied VideoInfo record with the results of calling
  10. most of the routines in GDTime.c. Under 1-bit QuickDraw it ignores the "card->device"
  11. argument.
  12.  
  13. HISTORY:
  14. 4/16/93    dgp set pages=1 for 1-bit qd.
  15. 4/26/93    dgp    test HasDepth before relying on it.
  16. 4/27/93    dgp    replaced HasDepth by GDHasMode.
  17. 7/29/94 dgp Eliminated use of "#s" printf format, since it's not supported by
  18.             Metrowerks CodeWarrior C.
  19. 9/5/94 dgp removed assumption in printf's that int==short.
  20. 10/5/95 dgp added call to GDGestalt() to get full version of video driver if available.
  21. */
  22. #include "VideoToolbox.h"
  23. #include "GDInfo.h"
  24.  
  25. OSErr GDInfo(VideoInfo *card)
  26. {
  27.     short pixelSize,pages,d,mode;
  28.     Rect r;
  29.     long qD;
  30.     ColorSpec cSpec;
  31.     char *s;
  32.     
  33.     Gestalt(gestaltQuickdrawVersion,&qD);
  34.     if(qD<gestalt8BitQD){
  35.         card->device=NULL;
  36.         sprintf(card->cardName,"%s","Original 1-bit QuickDraw");
  37.         sprintf(card->driverName,"%s","Original 1-bit QuickDraw");
  38.         for(d=1;d<6;d++)card->depth[d].pixelSize=0;
  39.         card->slot=0;
  40.         CopyQuickDrawGlobals();    // make sure qd is valid.
  41.         r=qd.screenBits.bounds;
  42.         card->width=r.right-r.left;
  43.         card->height=r.bottom-r.top;
  44.         card->depth[0].pixelSize=1;
  45.         card->depth[0].clutSize=2;
  46.         card->depth[0].pages=1;
  47.         card->depth[0].framesPerClutUpdate=NAN;
  48.         card->depth[0].framesPerClutUpdateHighPriority=NAN;
  49.         card->depth[0].framesPerClutUpdateQuickly=NAN;
  50.         card->depth[0].vblPerFrame=1.0;
  51.         card->d=0;
  52.         card->dacSize=1;
  53.         card->dacMask=((1<<card->dacSize)-1)<<(16 - card->dacSize);
  54.         card->basicTested=1;
  55.         return 0;
  56.     }
  57.     if(!card->basicTested){
  58.         // This info never changes, so get it only once
  59.         for(d=0;d<6;d++){
  60.             card->depth[d].pixelSize=0;
  61.             card->depth[d].mode=0;
  62.             card->depth[d].pages=0;
  63.         }
  64.         d=0;
  65.         for(mode=0x80;mode<=0x85 && d<6;mode++){
  66.             if(GDHasMode(card->device,mode,&pixelSize,&pages)){
  67.                 card->depth[d].mode=mode;
  68.                 card->depth[d].pixelSize=pixelSize;
  69.                 card->depth[d].pages=pages;
  70.                 d++;
  71.             }
  72.         }
  73.         sprintf(card->cardName,"%s",s=GDCardName(card->device));
  74.         DisposePtr(s);
  75.         if(GDGestaltIsOn(card->device)){
  76.             char stage[5]="\000dab\000";
  77.             NumVersion numVersion;
  78.             int error;
  79.             
  80.             error=GDGestalt(card->device,'vers',(UInt32 *)&numVersion);
  81.             if(!error)sprintf(card->driverName,"%s %d.%01u%01u"
  82.                 ,GDNameStr(card->device)
  83.                 ,(numVersion.majorRev/16)*10+numVersion.majorRev%16
  84.                 ,numVersion.minorAndBugRev/16,numVersion.minorAndBugRev%16
  85.                 ,stage[numVersion.stage/0x20]);
  86.         }else{
  87.             if(GDVersion(card->device)==0)sprintf(card->driverName,"%s"
  88.                 ,GDNameStr(card->device));
  89.             else sprintf(card->driverName,"%s version %d"
  90.                 ,GDNameStr(card->device),(int)GDVersion(card->device));
  91.         }
  92.         card->slot=GetDeviceSlot(card->device);
  93.         r=(**(**card->device).gdPMap).bounds;
  94.         card->width=r.right-r.left;
  95.         card->height=r.bottom-r.top;
  96.         card->dacSize=GDDacSize(card->device);        // Takes 200 µs.
  97.         card->dacMask=((1<<card->dacSize)-1)<<(16 - card->dacSize);
  98.         card->setEntriesQuickly=(GetCardType(card->device)!=0);
  99.         card->gdGetEntries=(0==GDGetEntries(card->device,0,0,&cSpec));
  100.         card->basicTested=1;
  101.     }
  102.     // d changes any time you call SetDepth, so update it every time.
  103.     for(d=0;d<6;d++)if(card->depth[d].mode==(**card->device).gdMode)card->d=d;
  104.     
  105.     // Collect information from the GDevice record
  106.     card->depth[card->d].pixelSize=(**(**card->device).gdPMap).pixelSize;
  107.     card->depth[card->d].clutSize=GDClutSize(card->device);
  108.     return 0;
  109. }
  110.  
  111. OSErr GDInfoTime(VideoInfo *card)
  112. {
  113.     int error=0;
  114.     short clutSize=0,d=card->d;
  115.     double frames,s,missingFrames,frameRate;
  116.     long qD;
  117.     printf(BLANKLINE);    
  118.     printf("%d-bit pixels: timing CopyBits . . ." "\r",(int)card->depth[d].pixelSize);
  119.     card->depth[d].movieRate=GDMovieRate(card->device,0);
  120.     printf(BLANKLINE);    
  121.     printf("%d-bit pixels: timing CopyBitsQuickly . . ." "\r",(int)card->depth[d].pixelSize);
  122.     card->depth[d].movieRateQuickly=GDMovieRate(card->device,1);
  123.     Gestalt(gestaltQuickdrawVersion,&qD);
  124.     if(qD>=gestalt8BitQD){
  125.         printf(BLANKLINE);    
  126.         printf("%d-bit pixels: timing cscSetEntries . . ." "\r",(int)card->depth[d].pixelSize);
  127.         error=GDTimeClut(card->device,GDSetEntries,clutSize,&s,&frames,&missingFrames,&frameRate);
  128.         if(error){
  129.             // Video driver won't load clut, so we can't time that, but we can still time fram rate.
  130.             frameRate=GDFrameRate(card->device);
  131.         }
  132.         card->depth[d].frameRate=frameRate;
  133.         card->depth[d].vblPerFrame=GDVBLRate(card->device)/frameRate;
  134.         card->depth[d].framesPerClutUpdate=frames;
  135.         card->depth[d].missingFramesPerClutUpdate=missingFrames;
  136.     }else{
  137.         card->depth[d].frameRate=GDFrameRate(NULL);
  138.         card->depth[d].vblPerFrame=1.0;
  139.         card->depth[d].framesPerClutUpdate=NAN;
  140.         card->depth[d].missingFramesPerClutUpdate=NAN;
  141.     }
  142.     if(qD>=gestalt8BitQD){
  143.         printf(BLANKLINE);    
  144.         printf("%d-bit pixels: timing GDSetEntriesByTypeHighPriority . . ." "\r",(int)card->depth[d].pixelSize);
  145.         error=GDTimeClut(card->device,GDSetEntriesByTypeHighPriority,clutSize,&s,&frames,&missingFrames,&frameRate);
  146.         card->depth[d].framesPerClutUpdateHighPriority=frames;
  147.         card->depth[d].missingFramesPerClutUpdateHighPriority=missingFrames;
  148.     }else{
  149.         card->depth[d].framesPerClutUpdateHighPriority=NAN;
  150.         card->depth[d].missingFramesPerClutUpdateHighPriority=NAN;
  151.     }
  152.     if(qD>=gestalt8BitQD && GetCardType(card->device)){
  153.         printf(BLANKLINE);    
  154.         printf("%d-bit pixels: timing SetEntriesQuickly . . ." "\r",(int)card->depth[d].pixelSize);
  155.         error=GDTimeClut(card->device,SetEntriesQuickly,clutSize,&s,&frames,&missingFrames,&frameRate);
  156.         card->depth[d].framesPerClutUpdateQuickly=frames;
  157.         card->depth[d].missingFramesPerClutUpdateQuickly=missingFrames;
  158.     }else{
  159.         card->depth[d].framesPerClutUpdateQuickly=NAN;
  160.         card->depth[d].missingFramesPerClutUpdateQuickly=NAN;
  161.     }
  162.     printf(BLANKLINE);    
  163.     card->timeTested=1;
  164.     card->depth[d].timeTested=1;
  165.     return error;
  166. }